import { request } from '@/utils/request';
import { RequestEnum } from '@/enums/httpEnum';

export const rusticApi = {
  rusticList: '/rustic/list',
  rusticDetail: '/rustic/detail',
  rusticAdd: '/rustic/add',
  rusticUpdate: '/rustic/update',
  rusticDelete: '/rustic/delete',
  rusticDisable: '/rustic/disable',
  getRusticAdmin: '/rustic/admin/getRusticAdmin',
};

export const createRustic = (data: API.CreateRusticParams) => {
  return request({
    url: rusticApi.rusticAdd,
    method: RequestEnum.POST,
    data,
  });
};

export const updateRustic = (data: API.UpdateRusticParams) => {
  return request({
    url: rusticApi.rusticUpdate,
    method: RequestEnum.PUT,
    data,
  });
};

export const deleteRustic = (params: { id: number }) => {
  return request({
    url: rusticApi.rusticDelete,
    method: RequestEnum.DELETE,
    params,
  });
};

export const disableRustic = (params: { id: number }) => {
  return request({
    url: rusticApi.rusticDisable,
    method: RequestEnum.POST,
    params,
  });
};

export const getRusticAdmin = (params: { rusticId: number }) => {
  return request({
    url: rusticApi.getRusticAdmin,
    method: RequestEnum.POST,
    params,
  });
};
